/*
 * @Author: EyeSklear 1814580085@qq.com
 * @Date: 2024-01-12 15:01:22
 * @LastEditors: LIFM0623 1944099171@qq.com
 * @LastEditTime: 2024-03-27 15:03:04
 * @FilePath: \Scene_Back\src\cameraalong\cameraalong.controller.ts
 * @Description:
 *
 * Copyright (c) 2024 by EyeSklear , All Rights Reserved.
 */
import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
} from '@nestjs/common';
import { CameraalongService } from './cameraalong.service';
import {
  CreateCameraalongDto,
  RawCameraalongDto,
} from './dto/create-cameraalong.dto';
import { Request } from 'express';
import { UpdateCameraalongDto } from './dto/update-cameraalong.dto';

@Controller('cameraalong')
export class CameraalongController {
  constructor(private readonly cameraalongService: CameraalongService) { }

  @Post('createCameraAlongItem')
  create(@Body() rawCameraalongDto: RawCameraalongDto,
  @Req() request: Request,) {
    const user = request.user;
    rawCameraalongDto.creator = (user as any).email;
    return this.cameraalongService.create(rawCameraalongDto);
  }

  @Get('findAll')
  findAll() {
    return this.cameraalongService.findAll();
  }

  @Get('findOne/:id')
  findOne(@Param('id') id: string) {
    return this.cameraalongService.findOne(id);
  }

  @Patch('update/:id')
  update(
    @Param('id') id: string,
    @Body() updateCameraalongDto: UpdateCameraalongDto,
  ) {
    return this.cameraalongService.update(id, updateCameraalongDto);
  }

  @Delete('remove/:id')
  remove(@Param('id') id: string) {
    return this.cameraalongService.remove(id);
  }
}
